define([
  'underscore',
  'backbone',
  
 '../models/innerLayoutModelInstance'
], function(_, Backbone
	, innerLayoutModelInstance){
		  var albumPictureItemView = Backbone.View.extend({
				tagName:  "li",
				template: _.template($('#albums-item-template').html()),
				events: {
				  "click .link"   : "openAlbum"
				},
				render: function() {
					var model = this.model.toJSON();
					var diffInHours = Math.floor((new Date() - new Date(model.updated)) / (1000*60*60));
					if(diffInHours <= 24){
						model.time = diffInHours + ' hour';				
						if (diffInHours != 1) {
							model.time = model.time + 's';
						}
					}else {
						var diffInDays = Math.floor(diffInHours / 24);
						model.time = diffInDays + ' day';
						if (diffInDays != 1) {
							model.time = model.time + 's';
						}
					}												
					if (model.numphotos != 1) {
						model.numphotos = model.numphotos + ' files';
					}else{
						model.numphotos = model.numphotos + ' file';
					}
					this.$el.html(this.template(model));
					return this;
				},
				openAlbum: function() {
					innerLayoutModelInstance.goForward(this.model.get('id'));
				}
		  });
			return albumPictureItemView;
});